﻿using ProjectFootball.MVC.Foundation;
using ProjectFootball.MVC.Foundation.ResourceLibrary;
using ProjectFootball.MVC.Models.EntityFramework.Entities;
using ProjectFootball.MVC.Models.RepositoryProviders;
using System;
using System.Web.Mvc;

namespace ProjectFootball.MVC.Areas.MatchArea.Controllers
{
    public class DetailsController : BaseController
    {
        #region Constructor
        public DetailsController(IRepositoryProvider provider)
            :base(provider)
        {
        }
        #endregion

        public ActionResult Index(Guid id)
        {
            Match match = Provider.MatchRepository.SingleByPrimaryKey(id);

            if (match == null)
                return RedirectHome;

            var matchSearchResultViewModel = match.GetSearchResultViewModel(User, SearchType.Details);

            return View(matchSearchResultViewModel);
        }

    }
}
